<template>
  <view>
    <view class="avatar">
      <image :src="$filters.filterImg(userInfo.avatar)" />
      <text>{{ userInfo.nickname }}</text>
    </view>
    <view class="list">
      <navigator class="item" url="/pages/mine/set">
        <text class="color-icon t-icon t-icon-shezhi1"></text>
        <text class="label">设置</text>
        <text class="iconfont icon-xiangyou1"></text>
      </navigator>
      <view class="item" hover-class="navigator-hover">
        <text class="color-icon t-icon t-icon-lianxikefu1"></text>
        <text class="label">联系客服</text>
        <text class="iconfont icon-xiangyou1"></text>
        <button open-type="contact"></button>
      </view>
      <navigator class="item" url="/pages/mine/about">
        <text class="color-icon t-icon t-icon-guanyuwomen1"></text>
        <text class="label">关于我们</text>
        <text class="iconfont icon-xiangyou1"></text>
      </navigator>
    </view>
    <view class="copyright">
      <text class="title">版权归酷柚易汛所有</text>
      <text class="version">版本号{{ version || '--' }}</text>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      userInfo: this.$store.state.userInfo,
      version: this.$store.getters.getSystemSetByName('sc_version')
    }
  },
  onShow() {
    // 如需实现 tab 选中态，要在当前页面下，通过 getTabBar 接口获取组件实例，并调用 setData 更新选中态
    const curPages = getCurrentPages()[0] // 获取当前页面实例
    if (typeof curPages.getTabBar === 'function' && curPages.getTabBar()) {
      curPages.getTabBar().setData({
        selected: 2
      })
    }
  }
}
</script>

<style lang="less" scoped>
.avatar {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 438rpx;
  image {
    width: 160rpx;
    height: 160rpx;
    border-radius: 50%;
  }
  text {
    margin-top: 20rpx;
    font-size: 48rpx;
    font-weight: bold;
    color: #111111;
  }
}

.list {
  .item {
    position: relative;
    display: flex;
    align-items: center;
    width: 702rpx;
    height: 100rpx;
    margin: 0 auto 20rpx;
    background: #ffffff;
    border-radius: 16rpx;
    &:last-child {
      margin-bottom: 0;
    }
    .color-icon {
      width: 40rpx;
      height: 40rpx;
      margin: 0 32rpx;
    }
    .label {
      font-weight: bold;
      color: #111111;
    }
    .icon-xiangyou1 {
      position: absolute;
      right: 32rpx;
      top: 50%;
      transform: translateY(-50%);
    }
    button {
      position: absolute;
      width: 100%;
      height: 100%;
      opacity: 0;
    }
  }
}

.copyright {
  position: fixed;
  left: 0;
  bottom: calc(60rpx + 48px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  font-size: 24rpx;
  color: #aaaaaa;
  .title {
    display: flex;
    align-items: center;
    &::before,
    &::after {
      content: '';
      display: inline-block;
      width: 100rpx;
      height: 1px;
      margin: 0 20rpx;
      background-color: #aaa;
    }
  }
  .version {
    margin-top: 20rpx;
  }
}
</style>
